<?php
    session_start();
    include "../database.php";
    
    if (isset($_POST['comment'])) {
        if ($_POST['comment'] != ""){
            $author_id = $_SESSION['id'];
            //$query = "SELECT current_project FROM user WHERE id = '$author_id'";
            //$project_id = mysql_fetch_array(executeQuery($query))[0];
            $post_id = $_POST['post_id'];
            $content = nl2br($_POST['comment']);

            //INSERT POST IN SQL
            $query = "INSERT INTO commentary (commentary_user_id, commentary_post_id, commentary_text) VALUES ('$author_id', '$post_id', '$content')";
            executeQuery($query);
        }
    }

    if (isset($_GET['delete_comm'])) {
        $comment_id = $_POST['delete_comment_id'];
        header("Location: ../project_wall.php");
        $queryComment = "DELETE FROM commentary WHERE commentary_id = '$comment_id'";
        executeQuery($queryComment);
        
        
    }
        header("Location: ../project_wall.php");

?>
